//
//  XSJISawItTableCell.m
//  YCH
//
//  Created by yuanyuan he on 2019/6/18.
//  Copyright © 2019 KN. All rights reserved.
//

#import "XSJISawItTableCell.h"
#import "UIImageView+WebCache.h"
//#import "Tool.h"

@interface XSJISawItTableCell()

@property (nonatomic, strong) UIImageView* iconView;
@property (nonatomic, strong) UILabel* nameLabel;
@property (nonatomic, strong) UIImageView* gradeView;
@property (nonatomic, strong) UILabel* levelLabel;
@property (nonatomic, strong) UILabel* titleLabel;
@property (nonatomic, strong) UILabel* timeLabel;

@end

@implementation XSJISawItTableCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self setup];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setup
{
    self.contentView.backgroundColor = ColorHex(0xffffff);
    [self.contentView addSubview:self.iconView];
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.gradeView];
    [self.contentView addSubview:self.levelLabel];
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.timeLabel];
    
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.width.height.mas_equalTo(48);
        make.centerY.equalTo(self.contentView);
    }];
    
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_iconView.mas_right).offset(5);
        make.top.mas_equalTo(10);
    }];
    
    [_gradeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_nameLabel.mas_right).offset(5);
        make.centerY.equalTo(self->_nameLabel);
    }];
    
    [_levelLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_gradeView.mas_right).offset(5);
        make.centerY.equalTo(self->_nameLabel);
    }];
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_iconView.mas_right).offset(5);
        make.top.equalTo(self->_nameLabel.mas_bottom).offset(5);
    }];
    
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-10);
        make.centerY.equalTo(self.contentView);
    }];
    
    //下面横线
    UIView *hLineView = [[UIView alloc] init];
    hLineView.backgroundColor = ColorHex(0xE6E7EB);
    [self.contentView addSubview:hLineView];
    
    [hLineView mas_makeConstraints:^(MASConstraintMaker *make)
     {
         make.left.mas_equalTo(15);
         make.right.mas_equalTo(-15);
         make.bottom.equalTo(self.contentView);
         make.height.mas_equalTo(0.5f);
     }];
    
}

//-(void)setSeenModel:(WhoSeenModel *)seenModel
//{
//    _seenModel = seenModel;
//    //显示头像
//    if (!kStringIsEmpty(_seenModel.picture))
//    {
//        [_iconView sd_setImageWithURL:[NSURL URLWithString:seenModel.picture]];
//    }
//    _nameLabel.text = _seenModel.name;
//    _timeLabel.text = [Tool Transaction:self.seenModel.scanTime];
//}

- (UIImageView *)iconView {
    if (_iconView == nil) {
        _iconView = [[UIImageView alloc] init];
        _iconView.layer.cornerRadius = 24;
        _iconView.clipsToBounds = YES;
        _iconView.image = [UIImage imageNamed:@"missportrait"];
    }
    return _iconView;
}

- (UILabel *)nameLabel {
    if (_nameLabel == nil) {
        _nameLabel = [[UILabel alloc] init];
        _nameLabel.textColor = ColorHex(0x312727);
        _nameLabel.font = [UIFont systemFontOfSize:14];
        _nameLabel.text = @"慕容琪琪";
    }
    return _nameLabel;
}

- (UIImageView *)gradeView {
    if (_gradeView == nil) {
        _gradeView = [[UIImageView alloc] init];
        _gradeView.image = [UIImage imageNamed:@"Miss2"];
    }
    return _gradeView;
}

- (UILabel *)levelLabel {
    if (_levelLabel == nil) {
        _levelLabel = [[UILabel alloc] init];
        _levelLabel.textColor = ColorHex(0x606060);
        _levelLabel.font = [UIFont systemFontOfSize:9];
        _levelLabel.text = @"Lv.3";
    }
    return _levelLabel;
}

- (UILabel *)titleLabel {
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.textColor = ColorHex(0x696969);
        _titleLabel.font = [UIFont systemFontOfSize:12];
        _titleLabel.text = @"神奇的小琪琪，加油~……";
    }
    return _titleLabel;
}

- (UILabel *)timeLabel {
    if (_timeLabel == nil) {
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.textColor = ColorHex(0x999999);
        _timeLabel.font = [UIFont systemFontOfSize:11];
        _timeLabel.text = @"04-15";
    }
    return _timeLabel;
}

@end
